package com.example.friend.controller;

import com.example.common.core.domain.R;
import com.example.friend.domain.user.dto.UserDTO;
import com.example.friend.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private IUserService iUserService;

    @PostMapping("/sentCode")
    public R<Void> sentCode(@RequestBody UserDTO userDTO) {
        log.info("/user/sentCode:userDTO{}", userDTO);
        iUserService.sentCode(userDTO);
        return R.ok();
    }

    @PostMapping("/code/login")
    public R<String> login(@RequestBody UserDTO userDTO) {
        log.info("/user/code/login:userDTO{}", userDTO);
        String login = iUserService.login(userDTO);
        return R.ok(login);
    }



//    @DeleteMapping("/logout")
//    public R<Void> logout(@RequestHeader(HttpConstants.AUTHENTICATION) String token) {
//        return toR(userService.logout(token));
//    }

}
